package 每日一题;

import java.util.Arrays;
import java.util.HashSet;

public class 重新排序得到2的幂 {

    public boolean reorderedPowerOf2(int n) {
        HashSet<String> set = new HashSet<>();
        for (int i = 1; i < 1e9 ; i*=2) {
            set.add(sort(i));
        }
        return set.contains(sort(n));
    }
    //将一个整数排序
    public String sort(int n){
        char[] chars = String.valueOf(n).toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    }

}
